﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LambdaToSql.Extended
{
    public static class StringExtended
    {
        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param> 
        /// <returns></returns>
        public static bool IsNullOrEmpty<T>(this T obj)
        {
            var flag = true;
            if (obj != null)
            {
                flag = false;
            }
            return flag;
        }

        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this Guid obj)
        {
            var flag = true;
            if (obj != null)
            {
                if (obj != Guid.Empty)
                {
                    flag = false;
                }
            }
            return flag;
        }

        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this Guid? obj)
        {
            if (obj == null)
            {
                return true;
            }
            return obj.Value.IsNullOrEmpty();
        }

        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this DateTime obj)
        {
            var flag = true;
            if (obj != null)
            {
                if (obj == DateTime.MinValue)
                {
                    flag = false;
                }
            }
            return flag;
        }

        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this DateTime? obj)
        {
            if (obj == null)
            {
                return true;
            }
            return obj.Value.IsNullOrEmpty();
        }

        /// <summary>
        /// 非空验证
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this string obj)
        {
            var flag = true;
            if (obj != null)
            {
                if (obj == string.Empty)
                {
                    flag = false;
                }
            }
            return flag;
        }
    }
}
